<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
	<control:grid id="goodsGrid" />
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){
			
		}
		
		ns.addIndex = 0;
		
		ns.addRow = function(){
			var shop_id = editGrid.$search.getData()[0]['value'];
			if(!shop_id){
				$.toast(1,'请先选择门店！');
				return false;
			}
			
			$.ajaxs("/admin/v1/shop_staff/getMaxId").then(function(res){
				ns.addIndex = (ns.addIndex || res.data)+1;
				editGrid.addRow([{
					bank_code: "",
					bank_name: "",
					base_pay: "0",
					code: "s-"+shop_id+"-"+ns.addIndex,
					entry_time: $.getDate("yyyy-MM-dd HH:mm:ss"),
					gh:('000'+ ns.addIndex).slice(-3),
					idcard: null,
					img: null,
					is_del: 0,
					mail: null,
					name: "",
					phone: "",
					shop_id: shop_id,
					status: 1,
					work_type: "",
					password:'c4ca4238a0b923820dcc509a6f75849b'
				}]);
			});
			
			
		}
		
		ns.deleteRow = function(){
			$.confirm("确定删除？",function(index){
				editGrid.deleteRow();    
				layer.close(index);
	    	});
		}
    
        //保存
        ns.save=function(){
        	var shop_id = editGrid.$search.getData()[0]['value'];
        	if(!shop_id){
				$.toast(1,'请先选择门店！');
				return false;
			}
        	
        	
        	$.ajaxs('/admin/v1/shop_staff/add',{
        		shop_id:shop_id,
        		data:JSON.stringify(editGrid.getRows())
        	}).then(function(res){
        		$.toast(1,"保存成功！");
        		editGrid.load();
        		parent.grid.load();
        	});
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



